home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
NOFLICKE
/
MBARMAIN.C1
< prev
next >
Wrap
Text File
|
1990-12-27
|
4KB
|
187 lines
#include <OSUtil.h>
#include <WindowMgr.h>
#include <MenuMgr.h>
#include <EventMgr.h>
#include <ToolBoxUtil.h>
#ifndef NULL
#define NULL 0
#endif
SysEnvRec SysEnv; /* Machine environment record */
Boolean WNEIsImplemented;
Boolean Suspended = false;
#define UnImplTrap 0xa89f
#define _WaitNextEvent 0xab60
void Init (void);
Boolean TrapAvailable (short, short);
void PositionRect (Rect *, Point *);
void PositionWindow (WindowPtr, Point *);
Boolean notDone = true;
MenuHandle AppleMenu, FileMenu, EditMenu, FlickerMenu, Flicker1Menu, Flicker2Menu;
WindowPtr AboutWPtr;
PicHandle AboutPic;
Boolean flickerEnabled = true;
Boolean flic1Enabled = true;
Boolean flic2Enabled = true;
Boolean editEnabled = true;
main ()
{
Init ();
while (notDone) {
EventLoop ();
}
RemoveMBarPatch ();
}
void Init ()
{
short menuID;
MaxApplZone ();
FlushEvents (everyEvent - diskMask, 0 );
InitGraf (&thePort);
InitFonts ();
InitWindows ();
InitMenus ();
TEInit ();
InitDialogs (NULL); /* install restart proc */
InitCursor ();
InitMBarPatch ();
/* Find out if WaitNextEvent is implemented. First get version 2 of the
environment record. */
SysEnvirons (2, &SysEnv);
WNEIsImplemented = (SysEnv.machineType < 0 ? false :
TrapAvailable (_WaitNextEvent, ToolTrap));
/* install our menus */
menuID = 128;
if (!(AppleMenu = GetMenu (menuID++)))
ExitToShell ();
if (!(FileMenu = GetMenu (menuID++)))
ExitToShell ();
if (!(EditMenu = GetMenu (menuID++)))
ExitToShell ();
if (!(FlickerMenu = GetMenu (menuID++)))
ExitToShell ();
if (!(Flicker1Menu = GetMenu (menuID++)))
ExitToShell ();
if (!(Flicker2Menu = GetMenu (menuID++)))
ExitToShell ();
AddResMenu (AppleMenu, 'DRVR'); /* add desk accessories */
InsertMenu (AppleMenu, 0);
InsertMenu (FileMenu, 0);
InsertMenu (EditMenu, 0);
InsertMenu (FlickerMenu, 0);
InsertMenu (Flicker1Menu, 0);
InsertMenu (Flicker2Menu, 0);
DrawMenuBar ();
/* get our window, and the about picture */
if (!(AboutWPtr = GetNewWindow (128, NULL, -1L)))
ExitToShell ();
if (!(AboutPic = GetPicture (128)))
ExitToShell ();
HNoPurge (AboutPic);
SizeWindow (AboutWPtr,
(*AboutPic)->picFrame.right - (*AboutPic)->picFrame.left,
(*AboutPic)->picFrame.bottom - (*AboutPic)->picFrame.top,
false);
PositionWindow (AboutWPtr, NULL);
SetPort (AboutWPtr);
ClipRect (&AboutWPtr->portRect);
}
Boolean TrapAvailable (tNumber, tType)
short tNumber;
short tType;
{
/* Check and see if a trap exists */
return (NGetTrapAddress (tNumber, tType) != NGetTrapAddress (UnImplTrap, ToolTrap));
}
void ShowHideAbout ()
{
if (((WindowPeek) AboutWPtr)->visible)
HideWindow (AboutWPtr);
else
ShowWindow (AboutWPtr);
}
void ShowAbout ()
{
ShowWindow (AboutWPtr);
}
void PositionRect (r, pt)
Rect *r;
Point *pt;
{
Rect screen;
short scrW, scrH;
short rW, rH;
short dH, dV;
Point tl;
screen = screenBits.bounds;
rW = r->right - r->left;
rH = r->bottom - r->top;
scrW = screen.right - screen.left;
scrH = screen.bottom - screen.top;
dH = -r->left + (scrW - rW)/2;
dV = -r->top + (scrH - MBarHeight - rH)/3 + MBarHeight;
OffsetRect (r, dH, dV);
tl.h = r->left;
tl.v = r->top;
*pt = tl;
}
void PositionWindow (wPtr, pt)
WindowPtr wPtr;
Point *pt;
{
Rect portRect;
Point tl;
if (!wPtr) {
if (pt) {
pt->h = -1;
pt->v = -1;
}
return;
}
portRect = wPtr->portRect;
PositionRect (&portRect, &tl);
MoveWindow (wPtr, portRect.left, portRect.top, false);
if (pt)
*pt = tl;
}